package com.wnhz.work.yz.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.baoyz.swipemenulistview.SwipeMenuListView;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.bean.LookDetailsBean;
import com.wnhz.work.yz.bean.SingleItemBean;
import com.wnhz.work.yz.view.MyListView;

import java.util.List;

/**
 * Created by Administrator on 2017/6/29 0029.
 */
public class Look2Adapter extends BaseAdapter {
    static final String TAG = "ProjectAdapter";

    private List<LookDetailsBean.InfoEntity.CateInfoEntity> data;
    private LayoutInflater layoutInflater;
    private Context context;

    public Look2Adapter(Context context, List<LookDetailsBean.InfoEntity.CateInfoEntity> data) {
        this.context = context;
        this.data = data;
        this.layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            // 获取组件布局
            convertView = layoutInflater.inflate(R.layout.single_all_item2, null);
            holder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            holder.tv_all_number = (TextView) convertView.findViewById(R.id.tv_all_number);
            holder.item_list = (MyListView) convertView.findViewById(R.id.list_item);

            // 这里要注意，是使用的tag来存储数据的。
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tv_name.setText(data.get(position).getCate_name());
        holder.tv_all_number.setText("共" + data.get(position).getData().size() + "件");
        holder.item_list.setAdapter(new Look2ListAdapter(context, data.get(position).getData()));

        return convertView;
    }

    public class ViewHolder {
        public TextView tv_name;
        public TextView tv_all_number;
        public MyListView item_list;
    }
}
